package client;

import java.util.HashMap;

public class ClientSession {

	public Client client;
	public Object userAccount;

	public Object getUserAccount() {
		return userAccount;
	}

	public void setUserAccount(Object userAccount) {
		this.userAccount = userAccount;
	}

	
	private static HashMap<String,ClientSession> sessions = new HashMap();

	public static ClientSession getClientSession(Client client) {
		if(sessions.get(client.getSessionId()) == null)
			try {
				ClientSession session = new ClientSession();
				session.client = client;
				sessions.put(client.getSessionId(), session);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		return sessions.get(client.getSessionId());
	}

	public void endSession() {
		setUserAccount(null);
		sessions.remove(client.getSessionId());
	}

	public static ClientSession getSessionByClientId(String clientId) {
		return sessions.get(clientId);
	}
	
}
